<!-- 研判任务-研判反馈 -->
<template>
  <div class="request-trial">
    <module-card>
      <template #header>警情信息</template>
      <edit-form :model="baseInfo" :fields="baseFields" :editable="false" v-bind="formAttrs"> </edit-form>
    </module-card>
    <edit-form :model="orderForm" :fields="orderFields" v-bind="formAttrs" :rules="rules">
      <template #item-fileHolders>
        <dg-upload v-model="orderForm.fileHolders" :server-url="'./'" size="30m" tip-msg="上传文件限制大小为 30M">
          <el-button type="primary" plain>上传文件</el-button>
          <template slot="fileList" slot-scope="{ type, name, size }">
            <i :class="`dg-icon-${type}`"></i>
            {{ `${name} (${size / 1024})KB` }}
          </template>
        </dg-upload>
      </template>
    </edit-form>
    <div class="request-trial__btns">
      <dg-button @click="() => $router.go(-1)">取消</dg-button>
      <dg-button type="primary" @click="handleSuccess" :loading="loading">确定</dg-button>
    </div>
  </div>
</template>
<script>
import EditForm from '@@/edit-form';
import { orderDetail, feedback } from '@/api/police';
export default {
  name: 'PolicJudgeFeedback',
  components: {
    EditForm
  },
  data() {
    return {
      loading: false,
      id: '',
      jqid: '',
      formAttrs: {
        col: 12,
        labelWidth: 'calc(7em + 12px)'
      },
      rules: {
        fknr: [{ required: true, message: '请填写反馈内容', trigger: 'blur' }]
      },
      baseFields: [
        { prop: 'bjnr', label: '报警内容', col: 16 },
        { prop: 'bjsj', label: '报警时间' },
        { prop: 'bjr', label: '报警人' },
        { prop: 'bjdh', label: '报警电话' },
        { prop: 'afdz', label: '案发地址' },
        { prop: 'zwfksj', label: '最晚反馈时间' },
        { prop: 'zlyq', label: '指令要求' }
      ],
      baseInfo: {},
      orderForm: {
        fknr: '',
        fileHolders: [],
        // yplx:'', // TODO:21号需求  增加研判类型字段，系统自动生成请求研判，此字段不在系统中展示
      },
      orderFields: [
        {
          prop: 'fknr',
          label: '反馈',
          col: 24,
          tag: 'el-input',
          tagBind: {
            type: 'textarea',
            rows: 3,
            placeholder: '请输入内容',
            maxlength:'200',
            showWordLimit:true,
          }
        },
        {
          prop: 'fileHolders',
          label: '附件'
        }
      ]
    };
  },
  mounted() {
    this.id = this.$route.params.id;
    this.jqid = this.$route.params.jqid;
    this.getDetail();
  },
  methods: {
    getDetail() {
      orderDetail(this.id).then(({ data }) => {
        this.baseInfo = data;
      });
    },
    handleSuccess() {
      this.loading = true;
      feedback({
        jqxxbh: this.jqid,
        ypzlid: this.id,
        ...this.orderForm
      })
        .then(() => {
          this.$message.success('反馈成功');
          this.loading = false;
          this.$router.go(-1);
        })
        .catch(() => {
          this.$message.warning('反馈失败');
          this.loading = false;
        });
    }
  }
};
</script>
<style scoped lang="scss">
.request-trial {
  background: #fff;
  padding: 20px;
  > div {
    background: #fff;
    margin-bottom: 12px;
    border-radius: 2px;
  }
  .request-trial__btns {
    margin-bottom: 20px;
  }
}
</style>
